package com.gobrs.async.core.engine;

import com.gobrs.async.core.GobrsAsync;
import com.gobrs.async.core.common.util.JsonUtil;
import com.gobrs.async.core.config.RuleConfig;
import com.gobrs.async.core.holder.BeanHolder;

import java.util.List;

public abstract class AbstractEngine implements RuleEngine {

    /**
     * 流程规则分析
     */
    @Override
    public void parse(String rule) {
        GobrsAsync gobrsAsync = BeanHolder.getBean(GobrsAsync.class);
        List<RuleConfig> rules = JsonUtil.string2Obj(rule, List.class);
        for (RuleConfig r : rules) {
            /**
             * 真正的规则执行者
             */
            doParse(r, false);
            /**
             * 触发准备执行任务
             */
            gobrsAsync.readyTo(r.getName());
        }
    }

}
